Don't allow native window > 65535 pixels
authorAlexander Larsson <alex@localhost.localdomain>
Thu, 22 Jan 2009 13:10:19 +0000 (14:10 +0100)
committerAlexander Larsson <alex@localhost.localdomain>
Thu, 2 Apr 2009 08:15:25 +0000 (10:15 +0200)
gdk/x11/gdkgeometry-x11.c
gdk/x11/gdkwindow-x11.c

index d42872994246a06964c0fd9108e8528353416961..891fd94721c9923c09aec580b42092bd46d51d8c 100644 (file)
@@ -165,14 +165,6 @@ struct _GdkWindowQueueItem
   } u;
 };
 
-static void
-move_resize (GdkWindow *window, GdkRectangle *pos)
-{
-  XMoveResizeWindow (GDK_WINDOW_XDISPLAY (window),
-                     GDK_WINDOW_XID (window),
-                     pos->x, pos->y, pos->width, pos->height);
-}
-
 void
 _gdk_window_move_resize_child (GdkWindow *window,
                               gint       x,
@@ -182,7 +174,6 @@ _gdk_window_move_resize_child (GdkWindow *window,
 {
   GdkWindowImplX11 *impl;
   GdkWindowObject *obj;
-  GdkRectangle new_info;
   
   g_return_if_fail (window != NULL);
   g_return_if_fail (GDK_IS_WINDOW (window)); 
@@ -190,18 +181,32 @@ _gdk_window_move_resize_child (GdkWindow *window,
   impl = GDK_WINDOW_IMPL_X11 (GDK_WINDOW_OBJECT (window)->impl);
   obj = GDK_WINDOW_OBJECT (window);
 
+  if (width > 65535 ||
+      height > 65535)
+    {
+      g_warning ("Native children wider or taller than 65535 pixels are not supported");
+      
+      if (width > 65535)
+       width = 65535;
+      if (height > 65535)
+       height = 65535;
+    }
+  
   obj->x = x;
   obj->y = y;
   obj->width = width;
   obj->height = height;
 
-  new_info.x = obj->x + obj->parent->abs_x;
-  new_info.y = obj->y + obj->parent->abs_y;
-  new_info.width = obj->width;
-  new_info.height = obj->height;
+  /* We don't really care about origin overflow, because on overflow
+     the window won't be visible anyway and thus it will be shaped
+     to nothing */
 
   _gdk_x11_window_tmp_unset_parent_bg (window, TRUE);
-  move_resize (window, &new_info);
+  XMoveResizeWindow (GDK_WINDOW_XDISPLAY (window),
+                    GDK_WINDOW_XID (window),
+                    obj->x + obj->parent->abs_x,
+                    obj->y + obj->parent->abs_y,
+                    width, height);
   _gdk_x11_window_tmp_reset_parent_bg (window, TRUE);
 }
 
index 39dbda50797f9fadfc91f1faba6d378e9884c646..8438ddfac661a4c8aa28e2bb4823f9ce07d34ffc 100644 (file)
@@ -778,6 +778,17 @@ _gdk_window_impl_new (GdkWindow     *window,
       g_object_ref (draw_impl->colormap);
     }
 
+  if (private->width > 65535 ||
+      private->height > 65535)
+    {
+      g_warning ("Native Windows wider or taller than 65535 pixels are not supported");
+      
+      if (private->width > 65535)
+       private->width = 65535;
+      if (private->height > 65535)
+       private->height = 65535;
+    }
+  
   xid = draw_impl->xid = XCreateWindow (xdisplay, xparent,
                                        private->x + private->parent->abs_x,
                                        private->y + private->parent->abs_y,